package com.dkd.manage.controller;

import com.dkd.common.annotation.Anonymous;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.manage.domain.Sales;
import com.dkd.manage.service.ISalesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

import static com.dkd.common.core.domain.AjaxResult.success;

/**
 * @author yjl03
 * @since 2025-04-23 星期三 14:39:42
 */
@Anonymous
@RestController
@RequestMapping("/manage/sales")
public class SalesController {
        @Autowired
    private ISalesService salesService; // 修改变量名为符合命名规范的小写形式
    @GetMapping("/getSalesList")

    public List<Sales> getSalesList() {
        try {
            return salesService.getSalesList(); // 调用服务层方法，避免自我递归
        } catch (Exception e) {
            // 捕获异常并记录日志，防止程序崩溃
            System.err.println("获取销售列表失败: " + e.getMessage());
            e.printStackTrace();
            return new ArrayList<>(); // 返回空列表作为默认值
        }
    }

}
